Skip to content

Update SEC_BOOT_CFG5 register size to 32 bits#25

Closed
ayodejiige wants to merge 1 commit intoOpenDevicePartnership:mainfrom
ayodejiige:ayodejiige/fix-imxrt-rom-boot-5-config
Closed

Update SEC_BOOT_CFG5 register size to 32 bits#25
ayodejiige wants to merge 1 commit intoOpenDevicePartnership:mainfrom
ayodejiige:ayodejiige/fix-imxrt-rom-boot-5-config

Conversation

@ayodejiige
Copy link
Copy Markdown
Contributor

No description provided.

@ayodejiige ayodejiige requested a review from a team as a code owner October 7, 2025 03:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the SEC_BOOT_CFG5 register definition to use 32 bits instead of 16 bits, aligning the implementation with the correct hardware specification.

  • Updated register size from 16 bits to 32 bits in both JSON configuration and generated Rust code
  • Modified internal storage from 2-byte to 4-byte array to accommodate the larger size
  • Updated all related type conversions and constants to maintain consistency

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
libs/imxrt-rom/src/registers/device.rs Updated Rust struct implementation to use 4-byte array and 32-bit size constant
libs/imxrt-rom/registers.json Changed register size specification from 16 to 32 bits

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Wassasin
Copy link
Copy Markdown
Contributor

Wassasin commented Oct 7, 2025

This particular register is 16 bits however. Probably the method to write OTP fuses has an issue instead.

2025-10-07-084127_1925x516_scrot

@Wassasin
Copy link
Copy Markdown
Contributor

Wassasin commented Oct 7, 2025

The problem is that for writing the register I have used chunks_exact, even though some registers are not a full OTP word large.

for (i, chunk) in data.chunks_exact(4).enumerate() {
// Safety: we have chunks of exactly 4 bytes, hence the conversion to [u8; 4] is safe.
let word = u32::from_le_bytes(unsafe { chunk.try_into().unwrap_unchecked() });
self.otp.write_fuse(address + i as u32, word, self.mode_locked)?;
}

@Wassasin
Copy link
Copy Markdown
Contributor

Wassasin commented Oct 7, 2025

Fixed in #26. You can close this PR.

@ayodejiige ayodejiige closed this Oct 7, 2025
JamesHuard pushed a commit that referenced this pull request Oct 7, 2025
We have a single device-driver definition of the OTP fuse registers, but
can access them both from shadow registers, as well as from the OTP ROM
API. In the OTP ROM API implementation writing to registers smaller than
32 bits did not do anything. See #25.

This is due to calling `chunks_exact` with a size of 4, which does not
yield any chunk if the remaining buffer cannot fit exactly that chunk:
https://github.com/OpenDevicePartnership/ec-slimloader/blob/76d6f5cc2a422e0aa0a1fcf23a5c81c251276f5a/libs/imxrt-rom/src/registers.rs#L114-L119

This PR streamlines how the OTP words are accessed between OTP ROM API
and shadow registers, and adds a few tests to validate that it does so
correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants